home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
forth
/
amiga
/
amigaker.arc
/
18.init
< prev
next >
Wrap
Text File
|
1987-12-30
|
8KB
|
202 lines
;
; 18.init
;
;
;
* Window (s -- 'window ) Variable holds the window after it is
; opened.
dc.l -1
dc.l link3
link3 set *-4
dc.b $86,'Windo',$80!'w'
cnop 0,2
_Window dc.l docreate
dc.l 0
* run (s -- ) Allows multiline colon compilation.
dc.w 0
dc.l link2
link2 set *-4
dc.b $83,'ru',$80!'n'
cnop 0,2
_run dc.l nest
dc.l _state,_fetch,_question_branch,1$
dc.l _right_bracket,_state,_fetch,_not
dc.l _question_branch,3$
dc.l _interpret
3$ dc.l _branch,2$
1$ dc.l _interpret
2$ dc.l _exit
* quit (s -- ) The main loop. Gets input from the terminal and
; interprets it.
dc.w -1
dc.l link1
link1 set *-4
dc.b $84,'qui',$80!'t'
cnop 0,2
_quit dc.l nest
dc.l _nest_lit,tibbuffer,_tick_tib,_store
dc.l _loading,_off
dc.l _left_bracket
1$ dc.l _rp0,_fetch,_rp_store,_status
dc.l _query,_run,_state,_fetch,_not
dc.l _question_branch,2$
dc.l _nest_dot_quote
dc.b 4,' ok',0
cnop 0,2
2$ dc.l _branch,1$
dc.l _exit
* warm (s -- ) Warm start routine.
dc.w -1
dc.l link3
link3 set *-4
dc.b $84,'war',$80!'m'
cnop 0,2
_warm dc.l nest
dc.l _true,_nest_abort_quote
dc.b 11,'Warm Start',0
cnop 0,2
dc.l _exit
* cold (s -- ) Cold start routine, first calls boot and if it
; was succesfull will continue and start the forth quit loop.
dc.w -1
dc.l link3
link3 set *-4
dc.b $84,'col',$80!'d'
cnop 0,2
_cold dc.l nest
dc.l _boot,_question_branch,1$
dc.l _setdic,_interpret
dc.l _quit
1$ dc.l _nest_lit,100,_nest_bye
dc.l _exit
* boot Deferred word, normally start.
dc.w -1
dc.l link2
link2 set *-4
dc.b $84,'boo',$80!'t'
cnop 0,2
_boot dc.l dodefer,_start
* start (s -- fl | t=ok. ) Default for boot.
; opens intuition, opens a window and opens a console device.
; If any problem the routine returns false.
; the window is defined at 'here_window', see forth.asm.
dc.w -1
dc.l link3
link3 set *-4
dc.b $85,'star',$80!'t'
cnop 0,2
_start dc.l nest
dc.l _Open_Dos
dc.l _Open_Intuition
dc.l _question_branch,1$
dc.l _nest_lit,here_window,_OpenWindow,_branch,2$
1$ dc.l _0,_exit
2$ dc.l _dup,_question_branch,3$
dc.l _dup,_Window,_store,_OpenConsole,_branch,4$
3$ dc.l _Close_Intuition,_0,_exit
4$ dc.l _not,_question_branch,5$
dc.l _Window,_fetch,_CloseWindow,_Close_Intuition
dc.l _0,_exit
5$ dc.l _true
dc.l _exit
* setdic This is a special routine, it puts the remainder of the
; command line in the terminal input buffer tib, and sets #tib.
; It then checks to see if the first word is a number and uses this number
; (in hex) as the size of the dictionary, and allocates a dictionary.
; This routine doesn't have a header; it's not visible.
_setdic dc.l nest
dc.l _sp0,_fetch,_dup,_4_plus,_fetch,_swap,_fetch
dc.l _dup,_number_tib,_store
dc.l _tib,_swap,_move
dc.l _bl,_tib,_number_tib,_fetch
dc.l _1_minus,_plus,_c_store
dc.l _hex,_bl,_word,_number_question
dc.l _question_branch,1$
dc.l _drop,_dp,_8_plus,_store,_branch,2$
1$ dc.l _2drop,_to_in,_off
2$ dc.l _decimal
dc.l _2,_dp,_8_plus,_fetch,_AllocMem
dc.l _dup,_0_equal,_question_branch,6$
dc.l _nest_lit,300,_nest_bye
6$ dc.l _dp,_2dup,_store,_4_plus,_store
dc.l _exit
* (bye) (s return code -- ) ;sets d0 to return code
dc.w -1 ; usefull for telling user
dc.l link0 ; which problem occurred.
link0 set *-4
dc.b $85,'(bye',$80!')'
cnop 0,2
_nest_bye dc.l *+4
move.l (sp),d0
move.l init_sp,sp
addq.l #8,sp
rts
* bye (s -- ) Exits to Amiga dos.
; Closes the console device, the window, any open files and any
; any open libraries.
dc.w -1
dc.l link2
link2 set *-4
dc.b $83,'by',$80!'e'
cnop 0,2
_bye dc.l nest
dc.l _CloseConsole
dc.l _Window,_fetch,_CloseWindow
dc.l _close_files
dc.l _close_libs
dc.l _dp,_4_plus,_dup,_fetch,_swap,_4_plus,_fetch
dc.l _FreeMem
dc.l _0,_nest_bye
dc.l _exit
* warm - warm start routine, low level
warm lea _warm,w ;point to warm routine
move.l (w)+,a0 ;get nest from warm routine
jmp (a0) ;and jump to nest
* cold - code cold start routine
; Sets the stack and the topstack, stores pointer to string from the command
; line. Opens exec, sets up registers and jumps to forth's cold routine.
cold
move.l sp,d1 ;get stack addr
sub.l 4(sp),d1 ;calculate top of stack
lea topstack,a1 ;point to topstack
move.l d1,(a1) ; and set it
move.l a0,-(sp) ;save string address
move.l d0,-(sp) ; and the length
lea init_sp,a0
move.l sp,(a0) ;and set SP0
lea execbase,a0 ;point to execbase
move.l 4,(a0) ; set execbase
lea rpstack,rp ;start the return stack
adda.l #rpstacksize,rp ; point to the end
lea init_rp,a0 ;
move.l rp,(a0)
lea next,a3 ;set up the next address
lea _cold,w ;point to cold start routine
move.l (w)+,a0
jmp (a0) ;and jump to it